<?php
namespace app\api\controller\service;

use app\common\controller\Api;
use think\Validate;
/**
 * 首页接口
 */
class Feedback extends Api
{
    protected $noNeedLogin = [''];
    protected $noNeedRight = ['*'];

    public function submitFeedback()
    {
        $uid = $this->auth->id;
        $post = input('post.','','trim,strip_tags,htmlspecialchars,xss_clean');
        $rule = [
            'mobile' => 'number',
            'content'=> 'require',
            'type'   => 'require',
        ];
        $msg = [
            'mobile.number'  => '手机号必须是数字',
            'content.require'=> '请填写反馈内容',
            'type.require'   => '请提交用户身份'
        ];
        $validate = new Validate($rule, $msg);
        $result = $validate->check($post);
        if (!$result) {
            $this->error($validate->getError());
        }
        $post['user_id'] = $uid;
        $applySkill = new \app\api\model\service\Feedback();
        $applySkill->data($post)->save();
        $this->success('反馈意见已提交');
    }
}
